from PIL import Image, ImageFilter

# apply a Gaussian blur to an image
img = Image.open("images/astronaut.jpg")
gaussian_img = img.filter(ImageFilter.GaussianBlur(5))
gaussian_img.show()

# apply a Median filter to an image
median_img = img.filter(ImageFilter.MedianFilter(7))
median_img.show()

# custom filters
grayscale_img = img.convert("L")
new_img = grayscale_img.filter(ImageFilter.Kernel((3, 3), [1, 0, -1, 5, 0, -5, 1, 0, 1]))
new_img.show()
